package leetcode.每日一题.模拟;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2023/1/29 10:01 PM
 * @description：https://leetcode.cn/problems/count-asterisks/
 */
public class 统计星号 {
    @Test
    public void test() {
        System.out.println(new Solution().countAsterisks("l|*e*et|c**o|*de|"));
    }

    class Solution {
        public int countAsterisks(String s) {
            int flag = 0;
            int cnt = 0;
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                switch (ch) {
                    case '|':
                        flag++;
                        break;
                    case '*':
                        if (flag % 2 == 0) {
                            cnt++;
                        }
                        break;
                }
            }
            return cnt;
        }
    }
}
